package com.bomb.voice.backNet;

import com.bomb.voice.net.RetrofitServiceManager;

import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by zhouwei on 16/11/10.
 */

public class VoiceBackLoader {
    private VoiceBackGroundApi mMovieService;

    public VoiceBackLoader() {
        mMovieService = RetrofitServiceManager.getInstance().create(VoiceBackGroundApi.class);
    }


    public Observable<AddAccountBean> addAccount(String appId, String appAccountId, long ti, String ver, String au) {
        return mMovieService.addAccount(appId, appAccountId, ti, ver, au)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    public Observable<AddAccountBean> disableAccount(String appId, String appAccountId, long ti, String ver, String au) {
        return mMovieService.disableAccount(appId, appAccountId, ti, ver, au)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    public Observable<AddAccountBean> enableAccount(String appId, String appAccountId, long ti, String ver, String au) {
        return mMovieService.enableAccount(appId, appAccountId, ti, ver, au)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
    public Observable<AddAccountBean> getAccount(String appId, String infoType, String info, long ti, String ver, String au) {
        return mMovieService.getAccount(appId, infoType, info, ti, ver, au)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    public interface VoiceBackGroundApi {

        @FormUrlEncoded
        @POST("addAccount")
        Observable<AddAccountBean> addAccount(@Field("appId") String appId, @Field("appAccountId") String appAccountId, @Field("ti") long ti, @Field("ver") String ver, @Field("au") String au);

        @FormUrlEncoded
        @POST("disableAccount")
        Observable<AddAccountBean> disableAccount(@Field("appId") String appId, @Field("appAccountId") String appAccountId, @Field("ti") long ti, @Field("ver") String ver, @Field("au") String au);

        @FormUrlEncoded
        @POST("enableAccount")
        Observable<AddAccountBean> enableAccount(@Field("appId") String appId, @Field("appAccountId") String appAccountId, @Field("ti") long ti, @Field("ver") String ver, @Field("au") String au);

        @FormUrlEncoded
        @POST("getAccount")
        Observable<AddAccountBean> getAccount(@Field("appId") String appId, @Field("infoType") String infoType, @Field("info") String info, @Field("ti") long ti, @Field("ver") String ver, @Field("au") String au);
//infoType	String	是	查询信息类型：1）飞语云账户号码；2）APP账户号码；3）手机号码
        //info	String	是	infoType对应的查询信息
    }
}
